<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
$item=$this->plugin_setting('setting');
if($_RQ['op']=='main'){
	$id=$_RQ['id'];
	if($id){
		$item=$this->get('mycar',array('id'=>$id));
		$item['code']=json_decode($item['code'],true);
	}else{
		$item['code']=array('p'=>'京','c'=>'A');
	}
	$return['item']=$item;
	$return['car_type']=$this->car_type;
	$return['car_color']=$this->car_color;
	$return['brands']=$this->car_brand();
	exi($return);
}
if($_RQ['op']=='set'){
	$postdata=get_postdata();
	if(!$postdata['code']['number']){
		exi('请填写车牌号','error');
	}
	if(!$postdata['brand']){
		exi('请选择品牌','error');
	}
	$data=array(
		'brand'=>$postdata['brand'],
		'brandimg'=>$postdata['brandimg'],
		'code'=>ijson_encode($postdata['code']),
		'color'=>$postdata['color'],
		'type'=>$postdata['type'],
		'images'=>ijson_encode($postdata['images']),
		'isdefault'=>$postdata['isdefault'],
	);
	if($postdata['id']){
		pdo_update('jy_cxjxiche_mycar',$data,array('id'=>$postdata['id']));
		exi('更新成功！','','/mycar/');
	}else{
		$data['mid']=$_SESSION['uid'];
		$data['uniacid']=$_SESSION['uniacid'];
		$data['createtime']=TIMESTAMP;
		pdo_insert('jy_cxjxiche_mycar',$data);
		exi('更新成功！','','/mycar/');
	}
}
?>